<?php
/*
  Template Name: User Profile
 */
include_once('includes/ys-upload-avatar/includes/config.php');
$current_user = wp_get_current_user(); // grabs the user info and puts into vars
$userId = $current_user->id;
$display_user_name = cp_get_user_name();

// dump($current_user->user_type);
// if(strcmp($current_user->user_type ,"2") ==0) {
//     echo "aaaaaaaaaaaaa";
// } else{
//     echo "sssssssss";
// }

//$meta_user = get_user_meta($userId);  

// dump($current_user);
//dump($meta_user);exit;

?>
<style>
    #id-profile-info{
        display: none;
    }
    #id-profile-account{
        display: none;
    }
    .line-cut{
        /*        border-top: 1px solid #2e9fd2;
                margin-top: 3px;*/
    }
    .previewWrapper {
        clear: left;
        float: left;
    }
    #div_upload_big {
        clear: left;
        float: left;
        padding: 0;
    }
    .uploader{
        display: none;
        position: fixed;
        top: 50px;
        left: 150px;
        z-index: 1010;
        right: 150px;
        background-color: white;
        height: 333px;
        width: 875px;
        margin-left: auto;
        margin-right: auto;
    }
    #close-icon {
        background: url("<?php echo get_template_directory_uri(); ?>/images/closebtn.png") no-repeat scroll 0 0 transparent;
        height: 30px;
        width: 30px;
        float:right;
        position: relative;
        top: -15px;
        right: -15px;
    }

    #close-icon:hover {
        background: url("<?php echo get_template_directory_uri(); ?>/images/closebtnhv.png") no-repeat scroll 0 0 transparent;
    }

    #upload_avatar_step2 {
        position: fixed;
        z-index: -1;
        top: 0px;
        left: 0px;
        height: 100%;
        width: 100%;
        background-color: #000000;
        opacity: 0.8;
    }
    .previewWindow {
      /*  margin-left: 85px;
        padding: 0 0 0 50px;
        width: 270px;
        margin-top: 35px;
        float:left;*/
        margin-left: 85px;
        padding: 0 0 0 50px;
        width: 200px;
        margin-top: 35px;
        float: left;
        height: 200px;
    }
    #uploaded {
        margin-top: 20px;
        margin-left: 10%;
        float: left;
        padding-bottom: 20px;
        width: auto
    }
    #mask{
        opacity: 0.8;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: black;
        z-index:1000;
        display: none;
    }
    #user-avatar-display {
        text-align: center;
        padding: 0 10px 10px;
        width: 170px;
        margin-left: 47px;
        background: #EEE;
        -moz-border-radius: 6px;
        -webkit-border-radius: 6px;
        border-radius: 6px;
    }
    #user-avatar-display-image{
        padding-top: 20px;
    }
    #big_uploader{
        display:none;
        height: 0px;
        width: 0px;
    }
    a.Calendar:link,a.Calendar:visited{
        background:url(<?php echo get_template_directory_uri(); ?>/images/calen.gif) no-repeat;
        width:20px;
        height:20px;
        display:inline-block;
        text-indent:-9999px;
        margin-left: -30px;
    }
        .user-area{
            display: none;
        }
        .shop-area{
            display: none;
        }

    .area-toggle{
        margin-left: 51px;
        margin-right: 20px;
        background-color: bisque;
        height: 35px;
    }
    .area-toggle:hover{
        background-color: burlywood;
    }
    .text-toggle{
        line-height: 36px;
        margin-left: 40px;
        cursor: pointer;
    }
    .icon-toggle{
        float: right;
        margin-right: 40px;
        margin-top: 9px;
        cursor: pointer;
        font-size: 30px
    }
    .icon-toggle:hover{
        color: brown;
    }
    .description{
      color: red;
    }

    .need{
     color: black;
    }

    .user-type{
     width: 100px;
     -moz-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
     -webkit-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
     box-shadow:inset 0px 1px 0px 0px #bbdaf7;
     background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5) );
     background:-moz-linear-gradient( center top, #79bbff 5%, #378de5 100% );
     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5');
     background-color:#79bbff;
     border:1px solid #84bbf3;
     display:inline-block;
     color:#ffffff;
     font-family:arial;
     font-size:15px;
     font-weight:bold;
     padding:6px 24px;
     text-decoration:none;
     text-shadow:1px 1px 0px #528ecc;
     text-align: center;
    }
    .user-type:hover {
     background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff) );
     background:-moz-linear-gradient( center top, #378de5 5%, #79bbff 100% );
     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff');
     background-color:#378de5;
    }
    .user-type:active {
     position:relative;
     top:1px;
    }
       


</style>
<!--<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/ys-upload-avatar/css/reset.css" />-->
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/css/styles.css" />
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/css/imgareaselect-default.css" />
<!-- <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> -->
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/includes/js/jquery-ui/jquery-ui.css" />
<script type="text/javascript" src="<?php echo get_template_directory_uri() . '/includes/js/jquery-ui.js'; ?>"></script>
<!-- <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> -->

 <!--<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/ys-upload-avatar/js/jquery-1.8.2.min.js"></script>-->
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/js/jquery.imgareaselect.min.js"></script>
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/js/effects.js"></script>
<script>
    var urlimage = "<?php echo get_template_directory_uri(); ?>/";
    var userType = "<?php echo $current_user->user_type; ?>";
    var userSex = "<?php echo $current_user->sex; ?>";
    var templateUrl = "<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/";
    var useMobile=<?php if ($deviceType == 'tablet' || $deviceType == 'phone') {echo 'true';} else {echo 'false';} ?>;
    var uploadContent ='<div id="uploaded">'+
        '<h3><strong>Crop hình đại diện</strong></h3>'+
        '<div id="div_upload_big" style="width:<?= $bigWidthPrev ?>px;height:<?= $bigHeightPrev ?>px;"></div>'+
        '<div class="uploadThumbWrapper">'+
        '<?php if ($deviceType == 'tablet' || $deviceType == 'phone') { ?>'+
            ' <div class="mobileSelection">'+
            '<a id="selLeft">left</a>'+
            '<a id="selRight">right</a>'+
            '<a id="selUp">up</a>'+
            '<a id="selDown">down</a>'+
            '<a id="selResize">bigger</a>'+
            '<a id="selResizeSmall">smaller</a>'+
            ' </div>'+<?php } ?>'+
    '<form name="upload_thumb" id="upload_thumb" class="uploaderThumbForm" method="post" action="<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/upload.php?act=thumb" target="upload_thumb_target">'+
        '   <input type="hidden" name="img_src" id="img_src" class="img_src" /> '+
        '   <input type="hidden" name="height" value="0" id="height" class="height" />'+
        '   <input type="hidden" name="width" value="0" id="width" class="width" />'+
        '   <input type="hidden" name="userid" value="<?php echo $userId; ?>" />'+
        '   <input type="hidden" id="y1" class="y1" name="y" />'+
        '   <input type="hidden" id="x1" class="x1" name="x" />'+
        '   <input type="hidden" id="y2" class="y2" name="y1" />'+
        '   <input type="hidden" id="x2" class="x2" name="x1" />'+      
        '   <input type="submit" id="btnCreateThumb" value="Tạo Hình Đại Diện" class="inputSubmit"/>'+
        '</form>'+
        ' <div id="notice2" class="notice">Đang xử lý...</div>'+
        '  </div>'+
        ' </div>'+
        ' </div>'+
        ' </div>'+                    
        ' <div class="previewWindow">'+
        ' <h3>Xem trước</h3>'+
        ' <div class="previewWrapper" style="width:<?= $bigWidthPrev ?>px;height:<?= $bigHeightPrev ?>px;"></div>'+
        '<div id="preview1">'+
        '</div>'+
        '</div>'+
        '<span id="close-icon"></span>';
</script>

<div id="mask"></div>
<div class="uploader" id="uploader"></div>
<div class="content">
    <div class="content_botbg">
        <div class="content_res">
            <!-- left block -->
            <div class="content_left">
                <div class="shadowblock_out">
                    <!--  add upload avatar here-->
                    <div id="big_uploader">
                        <form name="upload_big" id="upload_big" class="uploaderForm" method="post" enctype="multipart/form-data" action="<?php echo get_template_directory_uri(); ?>/includes/ys-upload-avatar/upload.php?act=upload" target="upload_target">
                            <div class="fileWrapper">
                                <input name="photo" id="file" class="fileInput" size="27" type="file" />
                            </div>
                            <input type="hidden" name="width" value="<?= $canvasWidth ?>" />
                            <input type="hidden" name="height" value="<?= $canvasHeight ?>" />              
                        </form>
                    </div>
                    <!-- first step upload image end -->

                    <div class="shadowblock">
                        <?php do_action('appthemes_notices'); ?>
                        <form name="profile" id="your-profile" action="" method="post">

                            <?php wp_nonce_field('app-edit-profile'); ?>

                            <input type="hidden" name="from" value="profile" />
                            <input type="hidden" name="checkuser_id" value="<?php echo $user_ID; ?>" />
                            <table class="form-table">
                                <tr>
                                    <th><label for="user_login"><?php _e('Hình đại diện:', APP_TD); ?></label></th>
                                    <td>
                                        <div id="user-avatar-display" class="submitbox">
                                            <p id="user-avatar-display-image"><img src="<?php echo get_template_directory_uri() . "/includes/ys-upload-avatar/uploads/" . $userId . "/" . $userId . ".jpg"; ?>" alt="" class=" avatar  avatar-150  photo user-1-avatar" width="150" height="150"></p>
                                            <a id="user-avatar-link" class="button-primary thickbox" href="javascript:void(0)" title="Cập nhật hình đại diện">Cập nhật hình đại diện</a> 
                                        </div>
                                    </td>
                                </tr>
                            </table>   
                            <div class="area-toggle" id="id-area-toggle-account">
                                <span class="text-toggle">Cập Nhật Thông Tin Tài Khoản</span>
                                <span class="icon-toggle" id="id-icon-toggle-account">+</span>
                            </div>
                            <table class="form-table" id="id-profile-account">
                                <tr>
                                    <th><label for="email"><?php _e('Email:', APP_TD); ?></label></th>
                                    <td><input type="text" name="email" class="regular-text" id="email" value="<?php echo esc_attr($current_user->user_email); ?>" disabled="true" /></td>
                                </tr>
                                <tr>
                                    <th><label for="pass1" id="lb-pass" title="Để trống nếu như bạn không muốn thay đổi."><?php _e('Mật khẩu mới:', APP_TD); ?></label></th>
                                    <td>
                                        <input type="password" name="pass1" class="regular-text" id="pass1" maxlength="50" value="" placeholder="Để trống nếu như bạn không muốn thay đổi"/><br />
                                         <div class="description" id="wrn-pass1"></div>   
                                    </td>
                                </tr>

                                <tr>
                                    <th><label for="pass1"><?php _e('Nhập lại mật khẩu:', APP_TD); ?></label></th>
                                    <td>
                                        <input type="password" name="pass2" class="regular-text" id="pass2" maxlength="50" value="" /><br />
                                        <div class="description" id="wrn-pass2"></div>   
                                    </td>
                                </tr>
                                <!--
                                <tr>
                                    <th><label for="pass1">&nbsp;</label></th>
                                    <td>
                                        <div id="pass-strength-result"><?php _e('Độ mạnh mật khẩu', APP_TD); ?></div><br/>
                                    </td>
                                </tr>
                                  -->
                            </table>
                            <div class="area-toggle" id="id-area-toggle-info">
                                <span class="text-toggle">Cập Nhật Thông Tin Cá Nhân</span>
                                <span class="icon-toggle" id="id-icon-toggle-info">+</span>
                            </div>
                            <table class="form-table" id="id-profile-info">
                                <?php if(strcmp($current_user->user_type,'0') == 0 || empty($current_user->user_type)){ ?>
                                <tr>
                                    <th><label for="user_login"><?php _e('Bạn là:', APP_TD); ?></label></th>
                                    <td>
                                        <div id="radio">
                                          <a href="javascript:void(0)" class="user-type"  id="id-radio-shop">Chủ shop</a>
                                          <a href="javascript:void(0)" class="user-type"  id="id-radio-user">Bình Thường</a>
                                        </div>
                                    </td>
                                </tr>    
                                <?php } ?>
   <!--user-area -->
                            <?php if(strcmp($current_user->user_type,'1') == 0 || empty($current_user->user_type)){ ?>
                               <tr class="user-area">
                                    <th><label for="user_login" id="lb-displayname" title="Tên hiển thị mà mọi người có thể thấy được"><?php _e('Tên hiển thị (*):', APP_TD); ?></label></th>
                                    <td>
                                    <input type="text" name="display_name" class="regular-text" id="user-displayname" value="<?php echo esc_attr($current_user->display_name); ?>" placeholder="Nhập tên hiển thị của bạn" maxlength="100" />
                                      <div class="description" id="wrn-displayname"></div>
                                    </td>
                                </tr>
                                <tr class="user-area">
                                    <th><label for="birthday"><?php _e('Ngày sinh:', APP_TD); ?></label></th>
                                    <td>
                                        <input type="text" name="birthday" class="regular-text" id="birthday-user" value="<?php if($current_user->birthday){echo $current_user->birthday;} else {echo date("d/m/Y");} ?>" maxlength="30"/>
                                         <div class="description" id="wrn-birthday"></div>
                                    </td>
                                </tr>
                                 <tr class="user-area">
                                    <th><label for="birthday">Giới Tính</label></th>
                                    <td>
                                            <input type="radio" id="sex-female" name="sex" class="sex-radio" checked="true" value="1">Nữ </input><br>
                                            <input type="radio" id="sex-male" name="sex" class="sex-radio" value="2">Nam</input><br>
                                            <input type="radio" id="sex-unknow" name="sex" class="sex-radio" value="3">Chưa xác định</input><br>
                                        
                                    </td>
                                </tr>

                                <tr class="user-area">
                                    <th><label for="phone"><?php _e('Số điện thoại (*):', APP_TD); ?></label></th>
                                    <td><input type="text" name="phone" class="regular-text need" id="user-phone" value="<?php echo ($current_user->phone);  ?>" maxlength="11" placeholder="Ví dụ: 0908608601"/>
                                    <div class="description" id="wrn-phone"></div>
                                    </td>
                                     
                                </tr>
                                <tr class="user-area">
                                    <th><label for="address"><?php _e('Địa chỉ (*):', APP_TD); ?></label></th>
                                    <td><input type="text" name="address" class="regular-text need" id="user-address" value="<?php echo esc_attr($current_user->address); ?>" maxlength="200" placeholder="Ví dụ: 182 Lê Đại Hành quận 11 Hồ Chí Minh"/>
                                     <div class="description" id="wrn-address"></div>
                                    </td>
                                      
                                </tr>
                                <tr class="user-area">
                                    <th><label for="description"><?php _e('Giới thiệu:', APP_TD); ?></label></th>
                                    <td><textarea name="description" class="regular-text" id="description" rows="10" cols="50" placeholder="Hãy giới thiệu về bạn"><?php echo esc_textarea($current_user->description); ?></textarea></td>
                                </tr>  
                                <?php } 
                                if (strcmp($current_user->user_type,'2') == 0 || empty($current_user->user_type)) { ?>
    <!--shop-area -->
                                 <tr class="shop-area">
                                    <th><label for="user_login" id="lb-displayname" title="Tên hiển thị mà mọi người có thể thấy được"><?php _e('Tên Shop (*):', APP_TD); ?></label></th>
                                    <td>
                                    <input type="text" name="display_name" class="regular-text" id="user_login" value="<?php echo esc_attr($current_user->display_name); ?>" placeholder="Nhập tên hiển thị của bạn" maxlength="100" />
                                    </td>
                                </tr>
                                <tr class="shop-area">
                                    <th><label for="person_boss">Người đại diện (*):</label></th>
                                    <td><input type="text" name="person_boss" class="regular-text" id="url" value="<?php echo $current_user->person_boss; ?>" placeholder="Nhập tên người đại diện cho shop" maxlength="100" /></td>
                                </tr>  
                                <tr class="shop-area">
                                    <th><label for="birthday"><?php _e('Ngày hoạt động:', APP_TD); ?></label></th>
                                    <td>
                                        <input type="text" name="start_day" class="regular-text need" id="birthday-shop" value="<?php echo $current_user->start_day; ?>" placeholder="Nhập ngày hoạt động của shop" maxlength="30"/>
                                    </td>
                                </tr>
                                <tr class="shop-area">
                                    <th><label for="hotline"><?php _e('Hotline (*):', APP_TD); ?></label></th>
                                    <td><input type="text" name="hotline" class="regular-text" id="url" value="<?php echo $current_user->hotline; ?>" maxlength="100" placeholder="Ví dụ: 0908608601"/></td>
                                </tr>  

                                <tr class="shop-area">
                                    <th><label for="Website"><?php _e('Website:', APP_TD); ?></label></th>
                                    <td><input type="website_link" name="website_link" class="regular-text" id="website-link-shop" value="<?php echo $current_user->user_url; ?>"  placeholder="http://yourstyle247.com" maxlength="100" /></td>
                                </tr>  
                                <tr class="shop-area">
                                    <th><label for="url"><?php _e('Yahoo:', APP_TD); ?></label></th>
                                    <td>
                                        <input type="text" name="yahoo_nick" class="regular-text" id="yahoo-nick-shop" value="<?php echo $current_user->yahoo_nick; ?>" maxlength="100"  placeholder="Nhập nick yahoo của shop" /></br>
                                        <span class="description need">Thêm dấu phẩy (') nếu nhập nhiều hơn một tài khoản</span>
                                    </td>
                                </tr>  
                                <tr class="shop-area">
                                    <th><label for="url"><?php _e('Skype:', APP_TD); ?></label></th>
                                    <td>
                                        <input type="text" name="skype_nick" class="regular-text" id="skype-nick-shop" value="<?php echo $current_user->skype_nick; ?>" maxlength="100" placeholder="Nhập nick skype của shop" /><br/>
                                        <span class="description need">Thêm dấu phẩy (') nếu nhập nhiều hơn một tài khoản</span>
                                    </td>

                                </tr>  
                                <tr class="shop-area">
                                    <th><label for="facebook_url"><?php _e('Facebook:', APP_TD); ?></label></th>
                                    <td><input type="text" name="facebook_url" class="regular-text" id="facebook-url" value="<?php echo $current_user->facebook_url; ?>" placeholder="Nhập fanpage facebook của shop"  maxlength="100" /></td>
                                </tr>  
                                <tr class="shop-area">
                                    <th><label for="slogan"><?php _e('Slogan:', APP_TD); ?></label></th>
                                    <td><input type="text" name="slogan" class="regular-text" id="islogan" value="<?php echo $current_user->slogan; ?>" maxlength="100" placeholder="Nhập slogan của shop" /></td>
                                </tr>  
                                <tr class="shop-area">
                                    <th><label for="description"><?php _e('Giới thiệu về shop:', APP_TD); ?></label></th>
                                    <td><textarea name="description_shop" class="regular-text" id="description-shop" rows="10" cols="50" placeholder="Giới thiệu về shop" ><?php echo esc_textarea($current_user->description_shop); ?></textarea></td>
                                </tr>

                                <?php } ?>

                            </table>

                            <br />

                            <br />
                            <p class="submit center">
                                 <input type="hidden" name="action" value="app-edit-profile" />
                                <input type="hidden" name="email" value="<?php  echo esc_attr($current_user->user_email); ?>" />
                                <input type="hidden" name="user_type" value="<?php  echo esc_attr($current_user->user_type); ?>" id="id-user-type"/>
                                <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_ID; ?>" />
                                <input type="hidden" name="admin_color" value="<?php echo esc_attr($current_user->admin_color); ?>" />
                                <input type="hidden" name="rich_editing" value="<?php echo esc_attr($current_user->rich_editing); ?>" />
                                 <input type="hidden" name="comment_shortcuts" value="<?php echo esc_attr($current_user->comment_shortcuts); ?>" />

                                <?php if (_get_admin_bar_pref('front', $user_ID)) { ?>
                                    <input type="hidden" name="admin_bar_front" value="true" />
                                <?php } ?>

                                <input type="submit" id="cpsubmit" class="btn_orange" style="width: 266px;margin-left: 10px;" value="<?php _e('Cập Nhật Thông Tin', APP_TD); ?>" name="submit" />
                            </p>

                        </form>

                    </div><!-- /shadowblock -->

                </div><!-- /shadowblock_out -->

            </div><!-- /content_left -->

            <?php get_sidebar('user'); ?>

            <div class="clr"></div>

        </div><!-- /content_res -->

    </div><!-- /content_botbg -->

</div><!-- /content -->
<!-- hidden iframe begin -->
<iframe id="upload_target" name="upload_target" src=""></iframe>
<iframe id="upload_thumb_target" name="upload_thumb_target" src=""></iframe>
<!-- hidden iframe end -->

